<?php
namespace Main\Controller;
use Think\Controller;
class AppController extends Controller {

    function __construct()
    {
        parent::__construct();
        $this->mid;
        $this->info();
    }

    private function info(){
        $this->mid = session('mid');
        if(empty($this->mid)){
            die($this->error('对不起，您没有登录！',U('Login/index')));
        }
        $this->assign('title','后台管理中心');
    }

    protected function get_where($whe = '1=1'){
        $get = I('get.');
        foreach($get as $k=>$v){
            if($v){
                if(is_numeric($v)){
                    $whe .= ' AND `'.$k.'` = '.$v;
                }else{
                    $whe .= ' AND `'.$k.'` LIKE\'%'.$v.'%\'';
                }
            }
        }
        $this->assign('get',$get);
        return $whe;
    }

    protected function page($count,$number=15){
        $page  = new \Think\Page($count,$number);
        $page->rollPage = 5;
        $page->setConfig('first', '首页');
        $page->setConfig('last', '末页');
        $page->lastSuffix = false;
        $show  = $page->show();
        $data['f'] = $page->firstRow;
        $data['l'] = $page->listRows;
        $this->assign('page',$show);
        return $data;
    }

    
}